package com.CST.controller.cb;


import com.CST.common.api.ResultObject;
import com.CST.entity.cb.BdAccount;
import com.CST.service.cb.IBdAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ly
 * @since 2021-12-08
 */
@Api(tags = {"成本/收入-用友系统对应"})
@RestController
@RequestMapping("/bdAccount")

public class BdAccountController {

    @Autowired
    private IBdAccountService targetService;

    @PostMapping("/getAccountSource")
    @ApiOperation("getAccountSource")
    public ResultObject getAccountSource(@RequestBody BdAccount entity) {
        if (entity.getSysid() == null || entity.getSysid().isEmpty()) {
            return ResultObject.errorReturn("SysID不能为空");
        }
        return ResultObject.successReturn(targetService.getAccountSource(entity));
    }

    @PostMapping("/getAccountOrgationSource")
    @ApiOperation("getAccountOrgationSource")
    public ResultObject getAccountOrgationSource(@RequestBody BdAccount entity) {
        if (entity.getSysid() == null || entity.getSysid().isEmpty()) {
            return ResultObject.errorReturn("SysID不能为空");
        }
        if(entity.getSysid().toLowerCase().equals("cost"))
        {
            entity.setEdParentCode("RD_CostUFIDARelation");
        }
        else
        {
            entity.setEdParentCode("RD_IncomeUFIDARelation");
        }
        return ResultObject.successReturn(targetService.getAccountOrgationSource(entity));
    }

    @PostMapping("/getCheck")
    @ApiOperation("getCheck")
    public ResultObject getCheck(@RequestBody BdAccount entity) {
        if (entity.getSysid() == null || entity.getSysid().isEmpty()) {
            return ResultObject.errorReturn("SysID不能为空");
        }
        return ResultObject.successReturn(targetService.getCheck(entity));
    }

}

